package gao.xiaolei.dao;

import gao.xiaolei.entity.TestRunLogStep;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("TestRunLogStepDao")
public interface TestRunLogStepDao extends JpaRepository<TestRunLogStep,String> {

    List<TestRunLogStep> findByTestRunLog(String testRunLog);

    // 更改步骤的结果
    @Modifying
    // update或者delete操作，在更新或者删除操作时，此注解必须加
    @Query(value = "update TestRunLogStep set isPass = :isPass where id = :id")
    public void updateIsPass(@Param("isPass") Integer isPass, @Param("id") String id);

    @Modifying
    public void deleteAllByTestRunLogIn(List<String> testRunLog);

    // 获取该测试执行记录的执行步骤的reasonId
    @Query(value = "select reasonId from TestRunLogStep where id = :id")
    public String getReasonId(@Param("id") String id);
}
